from pydantic import BaseModel
from sqlalchemy import Column, String, DateTime

from config import Base


class Task(Base):
    __tablename__ = "user_task"

    uuid = Column(String,primary_key=True, unique=True, nullable=False)
    name = Column(String, nullable=False)
    status = Column(String, nullable=False)
    end_time = Column(DateTime, nullable=False)
    user_id = Column(String, nullable=False)
    remark = Column(String, nullable=False)
    create_by = Column(String, nullable=False)
    create_time = Column(DateTime, nullable=False)
    update_by = Column(String, nullable=False)
    update_time = Column(DateTime, nullable=False)

    def to_dict(self):
        return {
            'uuid': self.uuid,
            'name': self.name,
            'status': self.status,
            'end_time': self.end_time,
            'user_id': self.user_id,
            'remark': self.remark,
            'create_by': self.create_by,
            'create_time': self.create_time,
            'update_by': self.update_by,
            'update_time': self.update_time
        }

class TaskObj(BaseModel):
    uuid: str
    name: str
    status: str
    end_time: str
    user_id: str
    remark: str
    create_by: str
    update_by: str
class TaskCreate(BaseModel):
    name: str
    status: str
    end_time: str
    user_id: str
    remark: str
    create_by: str
    update_by: str
class TaskUuid(BaseModel):
    uuid: str
